home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / langs / gfaxpert.lzh / GFAXPERT.LIB / STANMED.LST < prev    next >
Encoding:
File List  |  1986-10-19  |  7.2 KB  |  264 lines

  1. ' *** STANMED.LST ***           (delete this line)
  2. '
  3. ' ==============================================================================
  4. ' ********************
  5. ' ***         .GFA ***
  6. ' ********************
  7. ' *** this program runs in Medium resolution only
  8. '
  9. ' ------------------------------------------------------------------------------
  10. '                             *** Initiation ***
  11. '
  12. DEFWRD "a-z"                    ! word variables (-32768 to +32767) default !!
  13. @initio
  14. '
  15. ' @title.screen("TITLE",".. .... 1990",32)        ! activate in finished program
  16. ' ON BREAK GOSUB break                            ! activate in finished program
  17. '
  18. ' ------------------------------------------------------------------------------
  19. '                            *** Main Program ***
  20. '
  21. '
  22. '
  23. EDIT                            ! use this while developing program
  24. ' @exit                         ! use this in finished program
  25. '
  26. ' ------------------------------------------------------------------------------
  27. '                     *** Standard Globals and Array ***
  28. '
  29. > PROCEDURE initio
  30.   LOCAL w,h,n
  31.   '
  32.   CLS
  33.   @med.mode
  34.   '
  35.   @get.path(default.path$)
  36.   '
  37.   physbase%=XBIOS(2)            ! physical screen
  38.   logbase%=XBIOS(3)             ! logical screen
  39.   '
  40.   med.res!=TRUE
  41.   scrn.x.max=WORK_OUT(0)                              ! 639 (regular monitor)
  42.   scrn.y.max=WORK_OUT(1)                              ! 199
  43.   ~GRAF_HANDLE(char.width,char.height,w,h)            ! 8x8 font
  44.   scrn.col.max=DIV(SUCC(scrn.x.max),char.width)       ! 80
  45.   scrn.lin.max=DIV(SUCC(scrn.y.max),char.height)      ! 25
  46.   '
  47.   white=0             ! default Medium colors
  48.   black=1
  49.   red=2
  50.   green=3
  51.   DEFTEXT black,0,0,6
  52.   '
  53.   ' *** Standard Array color.index()
  54.   ' *** use this array to convert a VDI color-index into a 'SETCOLOR'-index
  55.   RESTORE col.index.med
  56.   DIM color.index(3)
  57.   FOR n=0 TO 3
  58.     READ color.index(n)
  59.   NEXT n
  60.   @standard.med.colors
  61.   '
  62.   col.index.med:
  63.   DATA 0,3,1,2
  64.   '
  65.   on!=TRUE
  66.   off!=FALSE
  67.   '
  68.   bel$=CHR$(7)
  69.   '
  70.   return$=CHR$(13)
  71.   esc$=CHR$(27)
  72.   help$=CHR$(0)+CHR$(98)
  73.   undo$=CHR$(0)+CHR$(97)
  74.   '
  75.   interpreter$="\GFABASIC.PRG"  ! change path if necessary
  76.   run.only$="\GFABASRO.PRG"     ! Run-Only Interpreter
  77.   start.gfa$="\START.GFA"       ! 'Shell' for GFA-programs
  78.   start.prg$="\GFASTART.PRG"    ! 'Shell' for compiled GFA-programs
  79.   '
  80. RETURN
  81. ' **********
  82. '
  83. ' ------------------------------------------------------------------------------
  84. '                          *** Standard Functions ***
  85. '
  86. DEFFN center$(text$)=SPACE$((scrn.col.max-LEN(text$))/2)+text$
  87. DEFFN rev$(txt$)=CHR$(27)+"p"+txt$+CHR$(27)+"q"
  88. DEFFN ink$(color)=CHR$(27)+"b"+CHR$(color.index(color))
  89. DEFFN paper$(color)=CHR$(27)+"c"+CHR$(color.index(color))
  90. '
  91. ' ------------------------------------------------------------------------------
  92. '                         *** Standard Procedures ***
  93. '
  94. > PROCEDURE med.mode
  95.   ' *** uses Procedure Exit
  96.   LOCAL m$,button
  97.   IF XBIOS(4)<>1
  98.     SOUND 1,10,12,4,25
  99.     SOUND 1,10,6,4,25
  100.     SOUND 1,10,12,4,50
  101.     SOUND 1,0
  102.     m$="Sorry, this|program runs in|Medium rez only"
  103.     ALERT 3,m$,1," OK ",button
  104.     @exit
  105.   ENDIF
  106. RETURN
  107. ' **********
  108. '
  109. > PROCEDURE get.path(VAR default.path$)
  110.   ' *** return default path (current drive and folder)
  111.   ' *** example - A:\GAMES\
  112.   ' *** WARNING : Procedure returns path$ only after CHDIR path$, else A:\
  113.   ' ***                          (even if program not in main directory !!)
  114.   LOCAL default.drive,default.drive$
  115.   CLR default.path$
  116.   default.drive=GEMDOS(&H19)
  117.   default.drive$=CHR$(default.drive+65)
  118.   default.path$=DIR$(default.drive+1)
  119.   IF default.path$<>""
  120.     default.path$=default.drive$+":"+default.path$+"\"
  121.   ELSE
  122.     default.path$=default.drive$+":\"
  123.   ENDIF
  124. RETURN
  125. ' **********
  126. '
  127. > PROCEDURE standard.med.colors
  128.   ' *** standard-colors for Medium resolution
  129.   LOCAL n,col$,r,g,b
  130.   RESTORE col.data
  131.   FOR n=0 TO 3
  132.     READ col$
  133.     r=VAL(LEFT$(col$))
  134.     g=VAL(MID$(col$,2,1))
  135.     b=VAL(RIGHT$(col$))
  136.     VSETCOLOR n,r,g,b
  137.   NEXT n
  138.   '
  139.   col.data:
  140.   DATA 777,000,700,060
  141. RETURN
  142. ' **********
  143. '
  144. > PROCEDURE title.screen(title$,datum$,height)
  145.   ' *** standard title-screen
  146.   ' *** uses Standard Globals and Standard Procedure Return.key
  147.   LOCAL x,y,col,lin,name$,x1,y1,x2,y2,i
  148.   CLS
  149.   HIDEM
  150.   DEFTEXT black,8,0,height
  151.   x=(scrn.x.max-LEN(title$)*height/2)/2
  152.   y=scrn.y.max/2
  153.   TEXT x,y,title$
  154.   LET name$="© Han Kempen"      ! that's me
  155.   col=(scrn.col.max-12)/2
  156.   lin=scrn.lin.max/2+6
  157.   PRINT AT(col,lin);name$
  158.   x1=(col-2)*8
  159.   y1=(lin-1)*char.height-4
  160.   x2=x1+LEN(name$)*8+16
  161.   y2=y1+char.height+8
  162.   BOX x1,y1,x2,y2
  163.   DEFLINE 1,3
  164.   DRAW x1+3,y2+2 TO x2+2,y2+2 TO x2+2,y1+3
  165.   LINE x1+3,y2+1,x2+2,y2+1
  166.   PRINT AT(col,lin+2);datum$
  167.   @return.key
  168.   COLOR black
  169.   DEFLINE 1,1
  170.   FOR i=0 TO y
  171.     BOX i,i,scrn.x.max-i,scrn.y.max-i
  172.   NEXT i
  173.   COLOR white
  174.   FOR i=y DOWNTO 0
  175.     BOX i,i,scrn.x.max-i,scrn.y.max-i
  176.   NEXT i
  177.   COLOR black
  178.   CLS
  179. RETURN
  180. ' **********
  181. '
  182. > PROCEDURE return.key
  183.   ' *** wait for <Return>
  184.   ' *** after pressing any other key, flashing 'RETURN' is turned off
  185.   ' *** uses Standard Globals
  186.   LOCAL w1$,w2$,temp$,in$
  187.   CLR in$
  188.   REPEAT
  189.   UNTIL INKEY$=""
  190.   GET 0,scrn.y.max-char.height,scrn.x.max,scrn.y.max,temp$
  191.   w1$="<RETURN>"
  192.   w2$=SPACE$(8)
  193.   PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;
  194.   WHILE in$=""                              ! wait for any key
  195.     PAUSE 30
  196.     SWAP w1$,w2$
  197.     PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;
  198.     in$=INKEY$
  199.   WEND
  200.   PUT 0,scrn.y.max-char.height,temp$,3    ! restore screen
  201.   WHILE in$<>return$                      ! wait for <Return>
  202.     in$=INKEY$
  203.   WEND
  204. RETURN
  205. ' **********
  206. '
  207. > PROCEDURE break
  208.   ' *** activate in main program with : ON BREAK GOSUB break
  209.   ' *** do not use while developing program !
  210.   LOCAL m$,k
  211.   ON BREAK CONT
  212.   m$="*** Break ***|Continue,|Run again|or Quit"
  213.   ALERT 3,m$,1,"CONT|RUN|QUIT",k
  214.   SELECT k
  215.   CASE 1
  216.     ON BREAK                            ! true break possible for emergency
  217.     m$="Freeze current|screen (press|any key to|continue)"
  218.     ALERT 2,m$,2,"YES|NO",k
  219.     IF k=1
  220.       REPEAT
  221.       UNTIL LEN(INKEY$) OR MOUSEK
  222.     ENDIF
  223.     ON BREAK GOSUB break
  224.   CASE 2
  225.     RUN
  226.   CASE 3
  227.     @exit
  228.   ENDSELECT
  229. RETURN
  230. ' **********
  231. '
  232. > PROCEDURE exit
  233.   ' *** exit program
  234.   CLS
  235.   IF EXIST(interpreter$) OR EXIST(run.only$)
  236.     ' *** program was run from (Run-Only) Interpreter
  237.     IF EXIST(start.gfa$)
  238.       CHAIN start.gfa$          ! back to 'shell'-program
  239.     ELSE
  240.       EDIT                      ! no shell
  241.     ENDIF
  242.   ELSE IF EXIST(start.gfa$)
  243.     ' *** can't find interpreter, but here is the 'shell'-program
  244.     CHAIN start.gfa$
  245.   ELSE IF EXIST(start.prg$)
  246.     ' *** compiled program started from shell
  247.     CHAIN start.prg$            ! back to shell
  248.   ELSE
  249.     ' *** compiled program
  250.     SYSTEM                      ! no shell
  251.   ENDIF
  252. RETURN
  253. ' **********
  254. '
  255. ' ------------------------------------------------------------------------------
  256. '                               *** Procedures ***
  257. '
  258. '
  259. '
  260. '
  261. ' ------------------------------------------------------------------------------
  262. '                                *** The End ***
  263. ' ==============================================================================
  264.